package io.renren.modules.project.controller;

import java.util.List;
import java.util.Map;

import io.renren.common.annotation.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.project.entity.ProjectLineInfoEntity;
import io.renren.modules.project.service.ProjectLineInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-11-07 09:37:49
 */
@RestController
@RequestMapping("/generator/projectlineinfo")
public class ProjectLineInfoController {
	@Autowired
	private ProjectLineInfoService projectLineInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("generator:projectlineinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ProjectLineInfoEntity> projectLineInfoList = projectLineInfoService.queryList(query);
		int total = projectLineInfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(projectLineInfoList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("generator:projectlineinfo:info")
	public R info(@PathVariable("id") String id){
		ProjectLineInfoEntity projectLineInfo = projectLineInfoService.queryObject(id);
		
		return R.ok().put("projectLineInfo", projectLineInfo);
	}
	
	/**
	 * 保存
	 */
	@SysLog("新增线路")
	@RequestMapping("/save")
	@RequiresPermissions("generator:projectlineinfo:save")
	public R save(@RequestBody ProjectLineInfoEntity projectLineInfo){
		projectLineInfoService.save(projectLineInfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@SysLog("修改线路")
	@RequestMapping("/update")
	@RequiresPermissions("generator:projectlineinfo:update")
	public R update(@RequestBody ProjectLineInfoEntity projectLineInfo){
		projectLineInfoService.update(projectLineInfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("generator:projectlineinfo:delete")
	public R delete(@RequestBody String[] ids){
		projectLineInfoService.deleteBatch(ids);
		
		return R.ok();
	}

	/**
	 * 列表
	 */
	@RequestMapping("/listAll")
	public R listAll(){
		List<ProjectLineInfoEntity> projectLineInfoList = projectLineInfoService.listAll();
		return R.ok().put("projectLineInfoList", projectLineInfoList);
	}
	
}
